/*
 *		source/controls/dateitem.js
 */

/* tazLoader - Download manager
 * Copyright (C) 2011 Timo Tegtmeier
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

enyo.kind({
	name:		"DateItem",
	kind:		"RowItem",
	layoutKind:	"HFlexLayout",
	align:		"center",

	components:	[{
		content:	$L("Date"),
		name:		"caption",
		flex:		1
	}, {
		name: 		"picker",
		kind: 		"DatePicker",
		label:		"",
		onChange:	"doChange",
		openPopup: 	function() {
			var p = this.$.popup;
			if (!p.isOpen) {
				p.openAtControl(this.$.client);
			}
		}
	}],

	published: {
		caption:	"",
		value:		new Date(),
		disabled:	false
	},

	events: {
		onChange:	""
	},

	getValue: function() {
		return this.$.picker.getValue();
	},

	setValue: function(value) {
		this.$.picker.setValue(value);
	},

	captionChanged: function() {
		this.$.caption.setContent(this.caption);
	},

	disabledChanged: function() {
		//this.$.picker.$.day.setDisabled(this.disabled);
		//this.$.picker.$.month.setDisabled(this.disabled);
		//this.$.picker.$.year.setDisabled(this.disabled);
	},

	create: function() {
		this.inherited(arguments);

		this.setValue(this.value);
		this.captionChanged();
		this.disabledChanged();
	}
});
